//
//  DoctorViewController.m
//  QuickCure
//
//  Created by 曹魏 on 16/9/15.
//  Copyright © 2016年 haoge. All rights reserved.
//

#import "DoctorMsgViewController.h"
#import "CWMessageModel.h"

@interface DoctorMsgViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong)CWMessageModel *model;
@property (nonatomic,weak)UITableView *tableView;
@end

static NSString *reuseID = @"cell";

@implementation DoctorMsgViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
}

- (void)setIndex:(NSNumber *)index
{
    _index = index;
    if(index.intValue == 1)
    {
        UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
        [self.view addSubview:tableView];
        self.tableView = tableView;
        [tableView setDataSource:self];
        [tableView setDelegate:self];
        tableView.sectionFooterHeight = 15;
        tableView.sectionHeaderHeight = 0;
        tableView.tableHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0.1)];
        return;
    }
    
    UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    [self.view addSubview:tableView];
    self.tableView = tableView;
    [tableView setDataSource:self];
    [tableView setSeparatorInset:UIEdgeInsetsMake(0, 500, 0, 0)];
   
    
}

- (CWMessageModel *)model
{
    if(!_model)
    {
        [CWMessageModel modelWithSuccess:^(CWMessageModel *model) {
            _model = model;

            [self.tableView reloadData];
        }];
    }
    return _model;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    if(self.index.integerValue == 1)
    {
        return self.model.receiving_settings.count;
    }
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if(self.index.integerValue == 1)
    {
        return 1;
    }
    return self.model.receiving_settings.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseID];
    if(!cell)
    {
        cell  = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseID];
    }
    
    UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 300, 30)];
    [cell.contentView addSubview:lable];
    
    [lable setText:[NSString stringWithFormat:@"就诊条件 %ld:  %@",indexPath.row,self.model.receiving_settings[indexPath.row]]];
    [lable setTextColor:[UIColor colorWithWhite:0.3 alpha:1]];
    
    
    if(self.index.intValue == 1)
    {
        [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
        [lable setText:[NSString stringWithFormat:@"医生简介: %ld",indexPath.section]];
    }
    [cell setSeparatorInset:UIEdgeInsetsMake(0, 500, 0, 500)];

    
    return cell;
    
}
@end









